package com.zipking.cloud.springbootmybatis.kafka;

import lombok.Data;
@Data
public abstract class TransformMetaData {
    /**
     * 获取统一数据
     */
    public final Material getMaterial(KafkaData source) {
        if (source != null) {
            Material material = new Material();
            material.setTitle(source.getTitle());
            material.setDescription(source.getDescription());
            material.setAuthor(source.getAuthor());
            material.setTags(source.getTags());
            MediaEnum mediaEnum = MediaEnum.create(source.getMediaName());
            material.setMedia(mediaEnum.getCode());
            material.setSpiderTime(source.getSpiderTime());
            material.setOssPath(source.getOssPath());
            //填充数据
            this.fill(source, material);
            return material;
        }
        return null;
    }

    /**
     * 填充数据
     */
    public abstract void fill(KafkaData source, Material material);
}